package com.webflux.demo.webfluxdemo.exception;

import org.springframework.http.ProblemDetail;
import org.springframework.web.ErrorResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@ControllerAdvice
//@RestControllerAdvice
// 全局异常处理
public class GlobalExceptionHandler {
    @ResponseBody
    @ExceptionHandler(ArithmeticException.class)
    public String error(ArithmeticException exp) {
        System.out.println("发生数学运算异常" + exp);
//        return ProblemDetail
//        return ErrorResponse
        return "服务器异常...";
    }

}
